'use strict'
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const {
		data: { client_id, openid },
	} = await uniCloud.request({
		url: 'https://graph.qq.com/oauth2.0/me',
		data: {
			access_token: event.access_token,
			fmt: 'json',
		},
	})
	const {
		data: { figureurl_2, nickname },
	} = await uniCloud.request({
		url: 'https://graph.qq.com/user/get_user_info',
		data: {
			access_token: event.access_token,
			oauth_consumer_key: client_id,
			openid,
		},
	})
	//返回数据给客户端
	return { openId: openid, avatar: figureurl_2, nickname }
}
